<template>
  <view>
    <!-- 头像和昵称区域 -->
    <view class="top-box">
      <image :src="userInfo.avatarUrl" class="userAvatar"></image>
      <text class="nickName">{{userInfo.nickName}}</text>
    </view>
    
    <!-- 主体区域 -->
    <view class="panel-list">
      <view class="panel">
        <view class="panel-body">
          <view class="panel-item">
            <text>8</text>
            <text>收藏的商品</text>
          </view>
          <view class="panel-item">
            <text>18</text>
            <text>关注的商品</text>
          </view>
          <view class="panel-item">
            <text>8</text>
            <text>收藏的店铺</text>
          </view>
          <view class="panel-item">
            <text>84</text>
            <text>足迹</text>
          </view>
        </view>
      </view>
    
      <view class="panel">
        <view class="title">
          <text>我的订单</text>
        </view>
        <view class="panel-body">
          <view class="panel-item">
            <image src="../../static/my-icons/icon1.png" class="icon"></image>
            <text>待付款</text>
          </view>
          <view class="panel-item">
            <image src="../../static/my-icons/icon2.png" class="icon"></image>
            <text>待收货</text>
          </view>
          <view class="panel-item">
            <image src="../../static/my-icons/icon3.png" class="icon"></image>
            <text>退款/退货</text>
          </view>
          <view class="panel-item">
            <image src="../../static/my-icons/icon4.png" class="icon"></image>
            <text>全部订单</text>
          </view>
        </view>
      </view>
    
      <view class="panel">
        <view class="panel-list-item">
          <text>收货地址</text>
          <uni-icons type="forward" size="16"></uni-icons>
        </view>
        <view class="panel-list-item">
          <text>联系客服</text>
          <uni-icons type="forward" size="16"></uni-icons>
        </view>
        <view class="panel-list-item" @click="logout">
          <text>退出登录</text>
          <uni-icons type="forward" size="16"></uni-icons>
        </view>
        
      </view>
    </view>
  
  </view>
</template>

<script>
  import { mapState, mapMutations } from 'vuex'
  export default {
    name:"my-info",
    data() {
      return {
        
      };
    },
    computed: {
      ...mapState('m_user', ['userInfo'])
    },
    methods: {
      ...mapMutations('m_user', ['updataAddress','updataUserInfo', 'upDataToken']),
      logout() {
        const that = this
        uni.showModal({
        	title: '提示',
        	content: '是否确认退出登录',
        	success: function (res) {
        		if (res.confirm) {
        			that.updataAddress({})
        			that.updataUserInfo({})
        			that.upDataToken('')
        		} else if (res.cancel) {
        			uni.showMsg('您已取消退出登录！')
        		}
        	}
        });
      }
    }
  }
</script>

<style lang="scss">
.top-box {
  height: 400rpx;
  background-color: #C00000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .userAvatar {
    width: 180rpx;
    height: 180rpx;
    border-radius: 90rpx;
    border: 2px solid white;
    box-shadow: 0 1px 5px black;
  }
  .nickName {
    font-size: 32rpx;
    color: white;
    margin-top: 20rpx;
  }
}

.panel-list {
  padding: 0 30rpx;
  position: relative;
  top: -20rpx;
  .panel {
      background-color: white;
      margin-bottom: 16rpx;
      border-radius: 16rpx;
      
    .title {
      line-height: 80rpx;
      font-size: 30rpx;
      padding-left: 20rpx;
      border-bottom: 1px solid #efefef;
    }
    .panel-body {
      display: flex;
      justify-content: space-around;
      padding: 20rpx 0;
      .panel-item {
        margin: 0 20rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        font-size: 26rpx;
        
        .icon {
          width: 70rpx;
          height: 70rpx;
        }
      }
    }
  }
  .panel-list-item {
    display: flex;
    justify-content: space-between;
    padding: 30rpx;
    font-size: 30rpx;
    border-bottom: 1px solid #efefef;
  }
}
</style>